WorkflowThread

Overview

A Workflow, in a context of a specific data. You will use this object for reading and writing a workflow based on a specific context and data.

  • From version: 2020.20

Properties

coordinates

coordinates: string

The coordinates are a delimited string that captures the exact data points that describe the context of the thread. For data cells and members the coordinates are a combination of members and measures that the workflow is related to.

const coordinatesText = document.getElementById("coordinates");
coordinatesText.innerText = workflowApi.currentThread.coordinates;

createdBy

createdBy: Contact

The information of the user that created the thread.

if(workflowApi.session.currentUser.id !==  workflowApi.currentThread.createdBy.id){
 	deleteButton.style.visibility='hidden';
	}

entries

entries: Entry[]

The list of entries in the thread. Each workflow thread has a list of entries. All the entries represent the thread's changes over time.

const firstEntry =  workflowApi.currentThread.entries[0];

expirationDate

expirationDate: Date

A date for the thread to be expired. An expired thread is hidden in the application.

workflowApi.currentThread.expirationDate = workflowApi.enums.ExpirationType.ThreeMonths;

hasDataSnapshot

hasDataSnapshot: boolean

A flag that indicates if a report snapshot should be added to the thread. Snapshots allow the report structure to be stored regardless of whether it changes in the future.

setHasDataSnapshotButton.onclick = () => {
     	workflowApi.currentThread.hasDataSnapshot = true;
}

hasReportSnapshot

hasReportSnapshot: boolean

A flag that indicates if a report snapshot should be added to the thread. Snapshots allow the report structure to be stored regardless of whether it changes in the future.

setHasReportSnapshotButton.onclick = () => {
    	workflowApi.currentThread.hasReportSnapshot = true;
}

id

id: string

The thread's unique id,

const threadId = workflowApi.currentThread.id;
console log(" The current thread id is: " + threadId);

isEmailParticipents

isEmailParticipents: boolean

A flag that indicate if the thread's contacts will get an email when a new entry is added.

setEmailParticipentsButton.onclick = () => {
    	workflowApi.currentThread.isEmailParticipents = true;
}

isReportSpecific

isReportSpecific: boolean

A flag that indicates if the thread is related to a specific report or slide. If this flag is false the user will see the thread in every report with the same data model and coordinates.

setReportSpecificButton.onclick = () => {
		workflowApi.currentThread.isReportSpecific = true;
}

subtitle

subtitle: string

The thread's subtitle or description. The subtitle gives the user a larger understanding of what the thread is about.

const detailsInput = document.getElementById("details");
detailsInput.value = workflowApi.currentThread.subtitle;
detailsInput.onkeyup = function(event) {
	const input = event.target.value;
	workflowApi.currentThread.subtitle = input;
}

title

title: string

The thread's title. The title gives the user a quick understanding of what the thread is about.

const subjectInput = document.getElementById("subject");
subjectInput.value = workflowApi.currentThread.title;
subjectInput.onkeyup = function(event){
	const input = event.target.value;
	workflowApi.currentThread.title = input;
}

type

The source object driving the thread. A thread could be created on one of those contexts : Cell , Member , Document and Component. You can use this type to indicate the context the Thread was created on.

if(workflowApi.currentThread.type === workflowApi.enums.WorkflowThreadType.Cell){
   	console.log("The current Thread is on a cell");
}

validation

validation: () => boolean

A function that is being used by the API infrastructure to indicate if a thread is valid for saving. You should use this to set a customize validation function to control when the thread is valid for saving or not.

cApi.currentThread.validation = () => {
	const currentEntry =  workflowApi.currentThread.entries[0];
	const tasks = document.getElementById('tasks
	return validateTaskList(currentEntry, tasks);
}

Type declaration

    • (): boolean
    • A function that is being used by the API infrastructure to indicate if a thread is valid for saving. You should use this to set a customize validation function to control when the thread is valid for saving or not.

      cApi.currentThread.validation = () => {
      	const currentEntry =  workflowApi.currentThread.entries[0];
      	const tasks = document.getElementById('tasks
      	return validateTaskList(currentEntry, tasks);
      }
      

      Returns boolean

Methods

addContacts

addContacts ( newContacts : Contact []): Promise<void>

This function adds contacts or users to the thread.

fucntion addAllUsersAsContacts(){
		workflowApi.currentThread.addContacts(workflowApi.utilities.getUsersAndRoles());
}

Parameters

  • newContacts:Contact[]

    Array of Contacts - the contacts you want to add for the thread

Returns Promise<void>

addNewEntry

addNewEntry (): Entry

This function adds a new entry to the thread.

createNewEntryButton.addEventListener('click', () => {
		const newEntry = workflowApi.currentThread.addNewEntry();
 	newEntry.save();
});

Returns Entry

Entry-The new Entry for you to add to the thread.

getContacts

getContacts (): Promise< Contact []>

Returns the list of contacts or users attached to a thread.

cApi.currentThread.getContacts().then((currentContact) =>{
		console.log(currentContact.name);
});

Returns Promise<Contact[]>

users in the app that get updates about the thread and can view it.

getEntriesByDate

getEntriesByDate ( startDate : Date): Entry []

This function returns all entries in a given thread from the specified date-time.

const entriesSinceYesterday = workflowApi.currentThread.getEntriesByDate(today.getDate() - 1);
console.log("The number of entries since yesterday is " + entriesSinceYesterday.length);

Parameters

  • startDate:Date

    the time from where to get the entries.

Returns Entry[]

the entries from a time that is relevant for your need.

getLastEntries

getLastEntries ( count : number): Entry []

This function returns the last set of entries in a given thread. Set the count argument to specify the number to return.

const currentEntry = workflowApi.currentThread.getLastEntries(1)[0];

Parameters

  • count:number

    The number of Entries that was last added.

Returns Entry[]

Entries that was last added.

notifyChangeToContacts

notifyChangeToContacts (): Promise<void>

This function triggers the framework to notify all of a thread's contacts that there is an update for this thread.

fucntion CancelThread(){
 	workflowApi.currentThread.title = "canceled:" + workflowApi.currentThread.title;
		workflowApi.currentThread.save().then(() =>{
			workflowApi.currentThread.notifyChangeToContacts();
 	});
}

Returns Promise<void>

removeContacts

removeContacts ( ids : string[]): Promise<void>

This function removes contacts from the thread.

fucntion removeAllContacts(){
		workflowApi.currentThread.getContacts().forEach((contact) =>{
			workflowApi.currentThread.removeContacts([contact.id]);
		});
}

Parameters

  • ids:string[]

    Array of string - id of contacts that you want to remove from the thread

Returns Promise<void>

removeEntry

removeEntry ( entryId : string): void

This function removes the selected entry object from the thread's entries list.

removeLastEntryButton.onclick = function(event) {
	 const lastEntry =  workflowApi.currentThread.getLastEntries(1)[0];
	 workflowApi.currentThread.removeEntry(lastEntry.id);
}

Parameters

  • entryId:string

    the entry that you want to delete's id

Returns void

removeThread

removeThread (): Promise<void>

This function removes a Thread by it's given id. You should use it when you require to remove the current thread or some other thread.

const removeThreadButton = document.createElement("button");
removeThreadButton.addEventListener('click', () => {
	workflowApi.currentThread.removeThread().then(() => {
 	workflowApi.canvas.closeWindow();
	});
});

Returns Promise<void>

save

save (): Promise<void>

This function saves changes made to the thread object.

workflowApi.onBeforeUnload = () => {
		workflowApi.currentThread.save();
}

Returns Promise<void>